package graph;


import java.util.zip.DeflaterOutputStream;

public class TestBFS {
    public static void main(String[] args) {
        // 用例2：单节点图（需调整GraphGenerator支持孤立节点）
        Integer[][] matrixSingle = {{1, 1, 0}};
        Graph graphSingle = GraphGenerator.createGraph(matrixSingle);
        new Code01_BFS().bfs(graphSingle.nodes.get(1)); // 输出：1
        System.out.println();

        // 用例3：链式结构
        Integer[][] matrixChain = {
                {1, 2, 0},
                {2, 3, 0},
                {3, 4, 0}
        };
        Graph graphChain = GraphGenerator.createGraph(matrixChain);
        new Code01_BFS().bfs(graphChain.nodes.get(1)); // 输出：1 2 3 4
        System.out.println();

        // 用例4：分叉结构
        Integer[][] matrixFork = {
                {1, 2, 0},
                {1, 3, 0},
                {2, 4, 0},
                {3, 5, 0}
        };
        Graph graphFork = GraphGenerator.createGraph(matrixFork);
        new Code01_BFS().bfs(graphFork.nodes.get(1)); // 输出：1 2 3 4 5
        System.out.println();
        // 用例5：有环图
        Integer[][] matrixCycle = {
                {1, 2, 0},
                {2, 3, 0},
                {3, 1, 0}
        };
        Graph graphCycle = GraphGenerator.createGraph(matrixCycle);
        new Code01_BFS().bfs(graphCycle.nodes.get(1)); // 输出：1 2 3
    }
}